
#ifndef __GAMEINPUT_H__
#define __GAMEINPUT_H__

#include <dinput.h>

class CGameInput
{
public:
	CGameInput();
	virtual ~CGameInput();

	int		Init(HINSTANCE hInst, HWND hWnd);
	int		Init_Keyboard();
	int		Init_Joystick(int min_x=-256, int max_x=256, 
						int min_y=-256, int max_y=256, int dead_band = 10);
	int		Init_Mouse();

	int		Read_Joystick();
	int		Read_Mouse();
	int		Read_Keyboard();

	int		Release_Joystick();
	int		Release_Mouse();
	int		Release_Keyboard();

	UCHAR	GetKeyState(UCHAR key)
	{
		return m_keyboard_state[key];
	}

	DIJOYSTATE* GetJoyState()
	{
		return &m_joy_state;
	}

	DIMOUSESTATE* GetMouseState()
	{
		return &m_mouse_state;
	}
	
	int		Shutdown();

	//tmp
	static char				m_joyname[80];				// name of joystick

protected:



	// directinput globals
	LPDIRECTINPUT8			m_lpdi;						// dinput object
	LPDIRECTINPUTDEVICE8	m_lpdikey;					// dinput keyboard
	LPDIRECTINPUTDEVICE8	m_lpdimouse;				// dinput mouse
	LPDIRECTINPUTDEVICE8	m_lpdijoy;					// dinput joystick
	GUID					m_joystickGUID;				// guid for main joystick

	// these contain the target records for all di input packets
	UCHAR					m_keyboard_state[256];		// contains keyboard state table
	DIMOUSESTATE			m_mouse_state;				// contains state of mouse
	DIJOYSTATE				m_joy_state;				// contains state of joystick
	int						m_joystick_found;			// tracks if joystick was found and inited

	HWND					m_hWnd;
};

#endif